home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’89 / Dialoger / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-15  |  691 b   |  54 lines  |  [TEXT/KAHL]

  1.     
  2. #include     <OSUtil.h>
  3.  
  4.  
  5. #define    INITA4()    _A4SET(0)
  6. #define SETUPA4()    _A4SET(1)
  7.  
  8.  
  9. char    *modalDTrap;
  10. short    watching;
  11.  
  12. main()
  13. {
  14.     asm {
  15.         movem.l    a1-a5/d0-d7,-(sp)    /* save the regs */
  16.         };
  17.     INITA4();
  18.     startup();
  19.     asm {
  20.         Movem.l    (sp)+,a1-a5/d0-d7    /* restore all regs */
  21.         };
  22. };
  23.  
  24.  
  25. startup()
  26. {
  27.     extern pascal void myModalDialog();
  28.         
  29.     watching = 0;
  30.     
  31.     modalDTrap   = (char *) NGetTrapAddress(0x191,ToolTrap);
  32.     
  33.     NSetTrapAddress(&myModalDialog,0x191,ToolTrap);
  34. };
  35.  
  36.  
  37. _A4SET(first)
  38. int    first;
  39. {
  40.     asm {
  41.          bra.s    @1
  42. a4save:    dc.l    0
  43. @1        nop
  44.         }
  45.         if (first == 0)
  46.             asm {     lea        @a4save,a4
  47.                     move.l    a0,(a4)
  48.                     move.l    a0,a4      }
  49.         if (first == 1)
  50.             asm    {     lea        @a4save,a4
  51.                     move.l    (a4),a4 }
  52. };
  53.     
  54.